package com.lry.sso.common.exception;

import com.lry.sso.common.entity.BaseEnum;
import com.lry.sso.common.entity.SysError;

import lombok.Data;

/**
 * 系统调用异常
 *
 * @author 李瑞益
 * @date 2019/11/16
 */
@Data
public class SysInvocationException extends RuntimeException {
    private static final long serialVersionUID = -5239784097334888856L;
    private Throwable cause;
    private SysError error;

    public SysInvocationException(SysError error) {
        super(error.getMessage());
        this.error = error;
    }

    public SysInvocationException(SysError error, Throwable cause) {
        super(error.getMessage(),cause);
        this.cause = cause;
        this.error = error;
    }

    public SysInvocationException(BaseEnum errorEnum) {
        this.error = new SysError(errorEnum.code(),errorEnum.message());
    }

    public SysInvocationException(String code, String message) {
        super(message);
        this.error = new SysError(code,message);
    }
}
